// componnent/tabbar/tabbar.js
var app = getApp()
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    //设置一个“变量”，Number表示数字类型，value:0表示默认值为0
    selected:{
      type:Number,
      value:0
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    
    color: "#7A7E83",
    selectedColor: "#CD5C5C",
    list: [
      {
      pagePath: "/pages/index/index",
      iconPath: "/static/tabbar/ic_menu_choice_nor.png",
      selectedIconPath: "/static/tabbar/ic_menu_choice_pressed.png",
      text: "首页"
    }, 
    {
      
      iconPath:"/static/tabbar/ic_menu_choice_nor.png",
      selectedIconPath:"/static/tabbar/ic_menu_choice_pressed.png",
      text:"发布"
    },
    {
      pagePath: "/pages/home/home",
      iconPath: "/static/tabbar/ic_menu_me_nor.png",
      selectedIconPath: "/static/tabbar/ic_menu_me_pressed.png",
      text: "我的"
    }]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      if(url){
        wx.switchTab({url})   //可以跳转到tabbar页面
      }else{
        if(app.globalData.userInfo){
          wx.navigateTo({
            url: '/pages/publish/publish',
          })
        }else{
          wx.navigateTo({
            url: '/pages/auth/auth',
          })
        }
      }

      
      // 只能跳转到非tabbar页面
      // wx.navigateTo({
      //   url: 'url',
      // })

      
    }
  }
})